-
Notifications
You must be signed in to change notification settings - Fork 179
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Localize placeholder based on first language #201
Conversation
lib/index.js
Outdated
* Otherwise, if language is provided in options, then use the localized string of the first language if available | ||
* Otherwise use the default | ||
*/ | ||
getPlaceholderText: function(){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should this method be private?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
related to https://github.com/mapbox/mapbox-gl-geocoder/pull/198/files#r265396617 but I think it's better to re-gen the docs with each commit and include them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch. Moved this to be a private method.
var localizedValue = localization.placeholder[language]; | ||
if (localizedValue) return localizedValue; | ||
} | ||
return 'Search'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you could also lookup 'en' in localization.placeholder, but I don't think it really matters.
* | ||
* If placeholder is provided in options, then use options.placeholder | ||
* Otherwise, if language is provided in options, then use the localized string of the first language if available | ||
* Otherwise use the default |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should add a JSDoc @returns
here for completeness.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me!
Implements the change suggested in #150 by localizing the placeholder value based on the provided language option set in the constructor.